/**
 * table无限滚动
 */
export default {
  mounted(el, binding) {
    let scrollTop = null;
    let tbody = el.querySelector(".el-scrollbar__wrap");
    let currentLimiting = false;
    el.tableInfiniteScrollFn = function () {
      scrollTop = this.scrollTop;

      if (!currentLimiting) {
        if (
          this.scrollHeight - this.scrollTop - parseInt(this.style.height) <=
          200
        ) {
          // debugger
          currentLimiting = !currentLimiting;

          binding.value(scrollTop);
        }
      }
    };

    tbody.scrollTop = scrollTop;
    tbody.addEventListener("scroll", el.tableInfiniteScrollFn);
    tbody = undefined;
  },
  unmounted(el) {
    // debugger
    let tbody = el.querySelector(".el-scrollbar__wrap");
    tbody.removeEventListener("scorll", el.tableInfiniteScrollFn);
    el.tableInfiniteScrollFn = undefined;
  },
}